<template>
	<view style="padding: 30rpx;">
		<view style="padding: 20rpx;border-radius: 16rpx;background-color: #fff;">
			<u-parse :html="content"></u-parse>
		</view>
		<view style="margin-top: 50rpx;" v-if="contentInfo.filePath">
			<u-button type="primary" @click="downClick()">点击下载附件</u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				content: '',
				contentInfo: ''
			}
		},
		onLoad(opt) {
			this.id = opt.id
			this.getInfo()
		},
		methods: {
			getInfo() {
				this.$u.get("/content/info/" + this.id).then(res => {
					if (res.success) {
						this.contentInfo = res.data
						this.content = res.data.content
					}
				})
			},
			downClick() {
				uni.showModal({
					title: '提示',
					content: '请复制链接到浏览器中查看',
					cancelText: '取消',
					confirmText: '复制链接',
					success: (res)=> {
						if (res.confirm) {
							console.log('用户点击确定');
							wx.setClipboardData({
								data: this.sysConstant.FILE_SRC_PATH + this.contentInfo.filePath, // url地址
								success(res) {}
							});
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});

			}
		}
	}
</script>

<style>

</style>